﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

/// <summary>
/// Summary description for NewsDAO
/// </summary>
public class NewsDAO
{
	public NewsDAO()
	{
		//
		// TODO: Add constructor logic here
		//
	}
    public DataTable SelectNews()
    {
        DataProvider _dataProvider = new DataProvider();
        _dataProvider.GetDataFromStore("TACO_SP_S_R_Select", new string[] { "@1", "@2", "@3" },
                     new object[] { "TACO_News", "", "1" });
        return _dataProvider;
    }

    public DataTable SelectNews(string str_Condition)
    {
        DataProvider _dataProvider = new DataProvider();
        _dataProvider.GetDataFromStore("VNVN_SP_S_R_Select", new string[] { "@1", "@2", "@3" },
                     new object[] { "TACO_News", str_Condition, "0" });
        return _dataProvider;
    }

    public DataTable SelectNews(string str_Col, string str_Table, string str_Condition)
    {
        DataProvider _dataPro = new DataProvider();
        _dataPro.GetDataFromStore("TACO_SP_S_R_Search", new string[] { "@1", "@2", "@3" },
                                                        new object[] { str_Col, str_Table, str_Condition });
        if (_dataPro.RowsCount > 0)
        {
            return _dataPro;
        }
        return _dataPro;
    }

    public bool DeleteNews(NewsDTO _NewsDTO)
    {
        DataProvider _dataProvider = new DataProvider();
        _dataProvider.GetDataFromStore("TACO_SP_S_E_DeleteNews", new string[] { "@ID" },
                     new object[] { _NewsDTO.News_ID });
        if (_dataProvider.RowsCount > 0)
        {
            return true;
        }
        return false;
    }

    public bool UpdateNews(NewsDTO _NewsDTO)
    {
        DataProvider _dataProvider = new DataProvider();
        _dataProvider.GetDataFromStore("TACO_SP_S_E_UpdateNews", new string[] { "@1", "@2", "@3", "@4" }, new object[] { 
                                    _NewsDTO.News_ID,                                   
                                    _NewsDTO.News_Content,
                                    _NewsDTO.Language_ID,
                                    _NewsDTO.News_Active });
        if (_dataProvider.RowsCount > 0)
        {
            return true;
        }
        return false;
    }

    public bool InsertNews(NewsDTO _NewsDTO)
    {
        DataProvider _dataProvider = new DataProvider();
        _dataProvider.GetDataFromStore("TACO_SP_S_E_InsertNews", new string[] { "@1", "@2", "@3", "@4", "@5" },
                     new object[] { _NewsDTO.News_ID,
                                    _NewsDTO.News_CreateDate,
                                    _NewsDTO.News_Content,
                                    _NewsDTO.Language_ID,                                    
                                    _NewsDTO.News_Active});
        if (_dataProvider.RowsCount > 0)
        {
            return true;
        }
        return false;
    }
}